﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace Ex8.ParseURL
{
    class ParseURL
    {
        static void URLParser(string text)
        {
            string expression = @"(?<protocol>\w+)://(?<server>(\w+\.|\w)+)(?<resource>(.|\s)*)";
            Regex regex = new Regex(expression);
            Match match = regex.Match(text);
            if (match.Success)
            {
                Console.WriteLine("[protocol] = {0}, [server] = {1}, [resource] = {2}"
                    , match.Groups["protocol"].Value, match.Groups["server"].Value, match.Groups["resource"].Value);
            }
            else
            {
                Console.WriteLine("Invalid parsing format!");
            }

        }
        static void Main(string[] args)
        {
            //string text = "http://www.devbg.org/forum/index.php";
            string text = "http://www.abv.bg/mente/sources/mente.aspx";
            URLParser(text);
        }
    }
}
